package com.b2.controller.web;

import com.b2.pojo.dto.BookDto;
import com.b2.pojo.entity.Book;
import com.b2.result.Result;
import com.b2.service.BookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/web/Book")
@Slf4j
@Api(tags = "绘本相关接口")
@CrossOrigin
public class BookController {



    @Autowired
    private BookService bookService;


    @ApiOperation("查看所有的绘本")
    @GetMapping("/check")
    public Result<List<Book>> check(Long id) {
        return bookService.check(id);
    }
    @ApiOperation("删除绘本")
    @DeleteMapping("/delete")
    public Result delete(Long id) {
        return bookService.delete(id);
    }
    @ApiOperation("添加绘本")
    @PostMapping("/add")
    public Result add(@RequestBody BookDto bookDto) {
        return bookService.add(bookDto);
    }
}
